import Utils from './index';
const baseApiUrl = "https://api.studin.com.cn/studin";



/**
 * api请求
 */
export default async (options)=>{

    const userInfo = await Utils.getLoginInfo();
    const data = {
        headers:{
            'Accept': 'application/json',
            'Content-Type': 'application/json',
            'SiLoginToken':userInfo?userInfo["accessToken"]:"eb1addc9f8ab68fb7ff04021af11776bf917cdb60846286ee4b845890a3bbd23fafb537c92b3584a8661d0118161ce956b7e5cdfdc5032a4c5557417101b6e98"
        },
        body:JSON.stringify(options.body),
        method:options.method
    }
    const url = baseApiUrl+options.url;
    console.log(`request:: {url:${url}}`);
    console.log("request:: ",data)
    let startTime = new Date().getTime();
    return fetch(url,data).then(data=>{
        let endTime = new Date().getTime();
        console.log("url = ",url,"data = ",data)
        console.log("time::",(endTime - startTime), " ms ");
        return data.json();
    });
}


